/**
 * 
 */
package edu.university.demo.system.entit;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotBlank;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;

/**
 * @author bjwsl-001
 *
 */ 
@Entity
@Table(name = "pt_song")
public class Song extends IdEntity{
	
	private String fileName;
	
	private String imageName;
	
	private String songName;
	
	private String lyricName;
	
	private String singer;
	
	private String album;
	
	private Date releaseDate;
	
	private Date inputTime;
	
	private SongInfo songInfo;
	
	@JoinColumn(name="song_info_id",unique=true)
	@OneToOne(cascade=CascadeType.ALL)
	public SongInfo getSongInfo() {
		return songInfo;
	}

	public void setSongInfo(SongInfo songInfo) {
		this.songInfo = songInfo;
	}

	@JsonIgnore
	private List<User> userList = Lists.newArrayList();

	/**
	 * 歌曲文件名
	 * */
	@NotBlank
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	/**
	 * 图片名
	 * */
	public String getImageName() {
		return imageName;
	}

	public void setImageName(String imageName) {
		this.imageName = imageName;
	}

	/**
	 * 歌曲名
	 * */
	public String getSongName() {
		return songName;
	}

	public void setSongName(String songName) {
		this.songName = songName;
	}
	
	/**
	 * 歌词名
	 */
	public String getLyricName() {
		return lyricName;
	}
	
	public void setLyricName(String lyricName) {
		this.lyricName = lyricName;
	}

	/**
	 * 歌手
	 * */
	public String getSinger() {
		return singer;
	}

	public void setSinger(String singer) {
		this.singer = singer;
	}

	/**
	 * 专辑
	 * */
	public String getAlbum() {
		return album;
	}

	public void setAlbum(String album) {
		this.album = album;
	}

	/**
	 * 歌曲发行日期
	 * */
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getReleaseDate() {
		return releaseDate;
	}

	public void setReleaseDate(Date releaseDate) {
		this.releaseDate = releaseDate;
	}

	/**
	 * 歌曲录入时间
	 * */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getInputTime() {
		return inputTime;
	}

	public void setInputTime(Date inputTime) {
		this.inputTime = inputTime;
	}

	// 多对多定义
		@ManyToMany(fetch=FetchType.LAZY)
		@JoinTable(name = "pt_user_song", joinColumns = { @JoinColumn(name = "song_id") }, inverseJoinColumns = { @JoinColumn(name = "user_id")})
	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	@Override
	public String toString() {
		return "Song [fileName=" + fileName + ", imageName=" + imageName
				+ ", songName=" + songName + ", singer=" + singer + ", album="
				+ album + ", releaseDate=" + releaseDate + ", inputTime="
				+ inputTime + ", userList=" + userList + "]";
	}
	
	
	
}
